package com.meowcook.mapper;

import com.meowcook.pojo.dto.MaterialAddDTO;
import com.meowcook.pojo.dto.MaterialUpdateDTO;
import com.meowcook.pojo.po.Material;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;
import org.mapstruct.factory.Mappers;

import java.util.List;

/**
 * Created with Intellij IDEA.
 * Description:
 * User: 28792
 * Date: 2025-05-15
 * Time: 19:01
 */
@Mapper(componentModel = "spring")
public interface MaterialPojoMapper {
    MaterialPojoMapper INSTANCE = Mappers.getMapper(MaterialPojoMapper.class);

    @Mappings({
            @Mapping(source = "name", target = "name"),
            @Mapping(source = "quantity", target = "quantity"),
            @Mapping(source = "unit", target = "unit"),
            @Mapping(source = "category", target = "category")
    })
    Material toPO(MaterialAddDTO materialAddDTO);

    @Mappings({
            @Mapping(source = "id", target = "id"),
            @Mapping(source = "name", target = "name"),
            @Mapping(source = "quantity", target = "quantity"),
            @Mapping(source = "unit", target = "unit"),
            @Mapping(source = "category", target = "category")
    })
    Material toPO(MaterialUpdateDTO materialUpdateDTO);

    @Mappings({
            @Mapping(source = "name", target = "name"),
            @Mapping(source = "quantity", target = "quantity"),
            @Mapping(source = "unit", target = "unit"),
            @Mapping(source = "category", target = "category")
    })
    List<Material> toPO(List<MaterialAddDTO> materialAddDTOS);

    @Mappings({
            @Mapping(source = "id", target = "id"),
            @Mapping(source = "name", target = "name"),
            @Mapping(source = "quantity", target = "quantity"),
            @Mapping(source = "unit", target = "unit"),
            @Mapping(source = "category", target = "category")
    })
    List<Material> updateToPO(List<MaterialUpdateDTO> materialUpdateDTOS);
}
